package com.prjsystem.service.impl;

import java.util.List;

import com.prjsystem.common.constant.CMSConstant;
import com.prjsystem.common.util.CMSUtil;
import com.prjsystem.dao.CVSDetailDao;
import com.prjsystem.dao.CVSViewDao;
import com.prjsystem.dao.CommonDao;
import com.prjsystem.entity.CVSBean;
import com.prjsystem.entity.CVSDetail;
import com.prjsystem.service.CVSService;

public class CVSServiceImpl implements CVSService{
	private CVSViewDao cvsViewDao;
	private CVSDetailDao cvsDetailDao;
	private CommonDao commonDao;
	private CVSBean cvsBean =  new CVSBean();
	private CVSDetail cvsDetail = new CVSDetail();

	public CVSBean getCvsView(CVSBean cvsBean) {
		cvsBean.setAllCvsList(cvsViewDao.searchCvs(cvsBean));
		cvsBean.setSelectListBean(commonDao.dropDowmList(CMSConstant.CVS_DP_TYPE_SEARCH_LIST));
		return cvsBean;
	}
	@Override
	public CVSBean searchCvsList(CVSBean cvsBean) {
		cvsBean.setSelectListBean(commonDao.dropDowmList(CMSConstant.CVS_DP_TYPE_DETAIL_LIST));
		return cvsBean;
	}
	@Override
	public CVSBean searchCvsInfoByCvsId(CVSBean cvsBean) {
		List<CVSDetail> cvsInfo = cvsViewDao.searchCvsInfoByCvsId(cvsBean);
		if(cvsInfo.size()>0&&cvsInfo!=null){
			cvsBean.setCvsDetail(cvsInfo.get(0));
			
		}
		cvsBean.setSelectListBean(commonDao.dropDowmList(CMSConstant.CVS_DP_TYPE_DETAIL_LIST));
		return cvsBean;
	}
	@Override
	public void modifyCvsInfo(CVSBean cvsBean) {
		
		if (!CMSUtil.isEmpty(cvsBean.getCvsId())) {
			cvsDetailDao.updateCvsInfoDetail(cvsBean.getCvsDetail());
		}
		else{
			cvsDetailDao.addCvsInfo(cvsBean.getCvsDetail());
		}
		
	}
	//deleteCVS
	@Override
	public void deleteCVS(CVSBean cvsBean) {
		
		cvsViewDao.deleteCVS(cvsBean.getCvsId());
		
	}

	public CVSViewDao getCvsViewDao() {
		return cvsViewDao;
	}
	public void setCvsViewDao(CVSViewDao cvsViewDao) {
		this.cvsViewDao = cvsViewDao;
	}
	public CVSDetailDao getCvsDetailDao() {
		return cvsDetailDao;
	}
	public void setCvsDetailDao(CVSDetailDao cvsDetailDao) {
		this.cvsDetailDao = cvsDetailDao;
	}
	public CommonDao getCommonDao() {
		return commonDao;
	}
	public void setCommonDao(CommonDao commonDao) {
		this.commonDao = commonDao;
	}
	public CVSBean getCvsBean() {
		return cvsBean;
	}
	public void setCvsBean(CVSBean cvsBean) {
		this.cvsBean = cvsBean;
	}

	public void setCvsDetail(CVSDetail cvsDetail) {
		this.cvsDetail = cvsDetail;
	}

	public CVSDetail getCvsDetail() {
		return cvsDetail;
	}

}
